/*
 *  Copyright 2008-2010 www.jrails.org
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.rails.extjs.ux.grid;

import org.rails.extjs.Option;
import org.rails.extjs.data.Store;
import org.rails.extjs.panel.grid.ColumnModel;
import org.rails.extjs.panel.grid.GridPanel;

public class TreeGrid extends GridPanel {

	public TreeGrid() {
		super();
	}

	public TreeGrid(Store store, ColumnModel colModel) {
		super(store, colModel);
	}

	public TreeGrid(Option configOptions) {
		super(configOptions);
	}

	public TreeGrid(String title, Store store, ColumnModel colModel) {
		super(title, store, colModel);
	}

	public TreeGrid(String id, String title, Store store, ColumnModel colModel) {
		super(id, title, store, colModel);
	}
	
	public void setRootVisible(Boolean rootVisible){
		addOption("rootVisible", rootVisible);
	}
	
	public Boolean isRootVisible(){
		return getBoolean("rootVisible",false);
	}
	
	public void setUseArrows(Boolean useArrows){
		addOption("useArrows", useArrows);
	}
	
	public Boolean isUseArrows(){
		return getBoolean("useArrows",true);
	}
	
	public void setLines(Boolean lines){
		addOption("lines", lines);
	}
	
	public Boolean isLines(){
		return getBoolean("lines",false);
	}
	
	public void setBorderWidth(Integer borderWidth){
		addOption("borderWidth", borderWidth);
	}
	
	public Integer getBorderWidth(){
		return getInteger("borderWidth",0);
	}
	
	@Override
	public String getClassName(){
		return getString("cls","x-treegrid");
	}
	
	public void setColumnResize(Boolean columnResize){
		addOption("columnResize", columnResize);
	}
	
	public Boolean isColumnResize(){
		return getBoolean("columnResize",true);
	}
	
	public void setEnableSort(Boolean enableSort){
		addOption("enableSort", enableSort);
	}
	
	public Boolean isEnableSort(){
		return getBoolean("enableSort",true);
	}
	
	public void setReserveScrollOffset(Boolean reserveScrollOffset){
		addOption("reserveScrollOffset", reserveScrollOffset);
	}
	
	public Boolean isReserveScrollOffset(){
		return getBoolean("reserveScrollOffset",true);
	}
	
	public void setEnableHdMenu(Boolean enableHdMenu){
		addOption("enableHdMenu", enableHdMenu);
	}
	
	public Boolean isEnableHdMenu(){
		return getBoolean("enableHdMenu",true);
	}
	
	public void setColumnsText(String columnsText){
		addOption("columnsText", columnsText);
	}
	
	public String getColumnsText(){
		return getString("columnsText","Columns");
	}
	
	public void setDataUrl(String dataUrl){
		addOption("dataUrl",dataUrl);
	}
	
	public String getDataUrl(){
		return getString("dataUrl","");
	}
	
	@Override
	public String getScript() {
		script = new StringBuffer("");
		createItems();
		script.append("new Ext.ux.tree.TreeGrid(");
		script.append(createOptions());
		script.append(")");
		return script.toString();
	}
	
}
